// 程序总线

// 关闭VSCode非必要报错
// ignore_for_file: prefer_const_constructors_in_immutables

import 'package:audioplayers/audioplayers.dart';
import 'package:crazy_mita_problem_project/pages/get_player_favourite_song_page/about_page.dart';
import 'package:crazy_mita_problem_project/pages/get_player_favourite_song_page/favourite_song_page.dart';
import 'package:flutter/material.dart';
// 引入Flutter动画框架
import 'package:animations/animations.dart';
import 'package:window_manager/window_manager.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();   // 确保程序主窗口已加载
  // 设置窗口参数
  WindowManager.instance.setTitle("疯狂米塔的小问题");
  // 设置窗口最小大小
  WindowManager.instance.setMinimumSize(const Size(1600,1000));
  runApp(
    MyApp()
  );
}

class MyApp extends StatefulWidget {
  MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

AudioPlayer player = AudioPlayer();   // 设定音频播放对象,以播放《红色高跟鞋》指定片段

class _MyAppState extends State<MyApp> {
  @override
  void initState ()    // 覆写父类构造函数预加载后面可能会加载的音频文件对象
    {
      super.initState();
      Future.delayed(Duration(seconds: 0)).then((_) async {
        await player.setReleaseMode(ReleaseMode.loop);     // 设置音频播放模式为循环播放
        await player.setSourceAsset("audio/stay_with_player.m4a");
      });
    }
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      // title: 'Flutter Demo',
      debugShowCheckedModeBanner: false,     // 关闭右上角调试的提示信息
      theme: ThemeData(
        // This is the theme of your application.
        //
        // TRY THIS: Try running your application with "flutter run". You'll see
        // the application has a purple toolbar. Then, without quitting the app,
        // try changing the seedColor in the colorScheme below to Colors.green
        // and then invoke "hot reload" (save your changes or press the "hot
        // reload" button in a Flutter-supported IDE, or press "r" if you used
        // the command line to start the app).
        //
        // Notice that the counter didn't reset back to zero; the application
        // state is not lost during the reload. To reset the state, use hot
        // restart instead.
        //
        // This works for code too, not just values: Most code changes can be
        // tested with just a hot reload.
        pageTransitionsTheme: PageTransitionsTheme(
          builders: {
            TargetPlatform.android:FadeThroughPageTransitionsBuilder(),
            TargetPlatform.linux:FadeThroughPageTransitionsBuilder(),
            TargetPlatform.macOS:FadeThroughPageTransitionsBuilder(),
            TargetPlatform.iOS:FadeThroughPageTransitionsBuilder(),
          },
        ),
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.purple.shade50),
      ),
      home: Pages_GetPlayerFavouriteSong(),
      routes: 
        {
          '/about_page':(context)=>Pages_AboutProgram(),
        },
    );
  }
}

